package com.example.jikeyoujikeyou.office_sz.model;

import org.json.JSONException;
import org.json.JSONObject;

/**
 * Created by sziit on 2018/1/3.
 */

public class HttpModel {

    public final static int REQUEST_SUCCESS = 0;
    public final static int REQUEST_FAIL = -1;
    String msg;
    String data;
    int code;

    public HttpModel() {
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public void setData(String data) {
        this.data = data;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public String getData() {
        return data;
    }

    public int getCode() {
        return code;
    }

    public HttpModel(String json) {
        try {
            JSONObject jsonObject = new JSONObject(json);
            msg = jsonObject.getString("message");
            data = jsonObject.getString("data");
            code = jsonObject.getInt("code");
        } catch (JSONException e) {
            msg = "后台返回数据有问题";
            code = REQUEST_FAIL;
        }
    }

    @Override
    public String toString() {
        return "HttpModel{" +
                "msg='" + msg + '\'' +
                ", data='" + data + '\'' +
                ", code=" + code +
                '}';
    }
}
